<?php
namespace app\index\controller;
use catetree\Catetree;
class Cate extends Base
{
    public function index($id)
    {
    	//获取栏目及其子栏目的id
    	$Cate=db('tp_cate');
    	$Catetree=new Catetree();
    	$CateID=$Catetree->childrenids($id,$Cate);
    	$CateID[]=$id;

    	//栏目下的所有文章
    	$map['cate_id']=array('IN',$CateID);
    	$artRes=db('tp_article')->where($map)->select();

    	//当前栏目的信息
    	$cates=$Cate->find($id);


    	// dump($CateID);die;

    	$ComCateRes=model('TpCate')->getComCates();//左侧普通分类
    	// dump($CateRes);die;
    	$this->assign(
    	 	[
    	 	'ComCateRes'=>$ComCateRes,
    	 	'artRes'=>$artRes,
    	 	'cates'=>$cates
    	 	]
    	);
        return view('cate');
    }
}
